package com.wkr.common;

import lombok.Data;
import lombok.ToString;

@Data
@ToString
public class CommonResponse<T> {
    private String code;
    private String msg;
    private T data;

    public static <T> CommonResponse<T> success(T data) {
        CommonResponse<T> response = new CommonResponse<>();
        response.setCode(Constants.SUCCESS_CODE);
        response.setMsg(Constants.SUCCESS_MSG);
        response.setData(data);
        return response;
    }

    public static <T> CommonResponse<T> fail(String failCode, String exceptionMsg) {
        CommonResponse<T> response = new CommonResponse<>();
        response.setCode(failCode);
        response.setMsg(exceptionMsg);
        return response;
    }
}
